package servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import entity.Student;
import service.StudentService;
import service.serviceImpl.StudentServiceimpl;

/**
 * Servlet implementation class ShowStu
 */
@WebServlet("/ShowstuServlet")
public class ShowstuServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public ShowstuServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// TODO Auto-generated method stub
		StudentService ser= new StudentServiceimpl();
		
		
		String sno=req.getParameter("studentId");
	    
	    Student stu= ser.searchById(Integer.parseInt(sno));
	
		System.out.println(stu);
		req.setAttribute("stu", stu);
		req.setAttribute("uid", stu.getSno());
		System.out.println(stu);
		req.getRequestDispatcher("/student.jsp").forward(req, resp);
		
	}
}
